#include "StdAfx.h"
#include "Parallelogram.h"

CParallelogram::CParallelogram(void)
{
}

CParallelogram::CParallelogram(UINT type,CPoint pt)
{
	m_DrawType=type;
	m_Selected = 0;
	Point=pt;
	PrePoint=pt;
	Height=80;
	Width=120;
	m_point[1].x = pt.x - (Width+40)/2;
	m_point[1].y = pt.y - Height/2;
	m_point[2].x = pt.x;
	m_point[2].y = pt.y - Height/2;
	m_point[3].x = pt.x + (Width+40)/2;
	m_point[3].y = pt.y - Height/2;
	m_point[4].x = pt.x + (Width+40)/2;
	m_point[4].y = pt.y;
	m_point[5].x = pt.x + (Width+40)/2;
	m_point[5].y = pt.y + Height/2;
	m_point[6].x = pt.x;
	m_point[6].y = pt.y + Height/2;
	m_point[7].x = pt.x - (Width+40)/2;
	m_point[7].y = pt.y + Height/2;
	m_point[8].x = pt.x - (Width+40)/2;
	m_point[8].y = pt.y;
}

void CParallelogram::Draw(CDC *pDC)
{
	CPoint pt[4];
	
	pt[0]=CPoint(3*m_point[1].x/4+m_point[3].x/4,m_point[1].y);
	pt[1]=m_point[3];
	pt[2]=CPoint(3*m_point[5].x/4+m_point[7].x/4,m_point[5].y);
	pt[3]=m_point[7];
	pDC->Polygon(pt,4);
	if(m_Selected >= 1)
		ShowTracker(pDC);
}


void CParallelogram::SetWH()
{
	Width = 3*(m_point[3].x-m_point[1].x)/4;
	Height = m_point[7].y - m_point[1].y;
}

CParallelogram::~CParallelogram(void)
{
}
